package cn.edu.scau.cmi.zhengweixin.singleton;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.zhengweixin.singleton.MarshalMultipleton.Marshal;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;


public class MultipletonController {

    @FXML
    private ResourceBundle resources;

    @FXML
    private URL location;

    @FXML
    private TextField nameTextField;

    @FXML
    private TextArea outputTextArea;


    @FXML
    void createMarshal(ActionEvent event) {
    	String name = nameTextField.getText();
    	Marshal marshal = MarshalMultipleton.getRandomInstance(name);
    	outputTextArea.appendText("元帅列表为：" + MarshalMultipleton.getList() + ",出战的元帅为：" + marshal.toString() + "\n");
    }

    @FXML
    void initialize() {
        assert nameTextField != null : "fx:id=\"nameTextField\" was not injected: check your FXML file 'Multipleton.fxml'.";
        assert outputTextArea != null : "fx:id=\"outputTextArea\" was not injected: check your FXML file 'Multipleton.fxml'.";
    }

}
